//
//  SMPrizeTitleView.m
//  SMTools
//
//  Created by fengsh on 2019/1/14.
//  Copyright © 2019年 fengsh. All rights reserved.
//

#import "SMPrizeTitleView.h"
#import <Masonry/Masonry.h>

@interface SMPrizeTitleView()
@property (nonatomic, strong) NSView                                *topview;
@property (nonatomic, strong) NSTextField                           *left_line;
@property (nonatomic, strong) NSTextField                           *right_line;
@end

@implementation SMPrizeTitleView

- (instancetype)initWithFrame:(NSRect)frameRect
{
    self = [super initWithFrame:frameRect];
    if (self) {
        self.lb_title = [[NSTextField alloc]init];
        [self.lb_title setEditable:NO];
        [self.lb_title setSelectable:NO];
        [self.lb_title setBezeled:NO];
        [self.lb_title setBordered:NO];
        [self.lb_title setAlignment:NSTextAlignmentCenter];
        [self.lb_title setStringValue:@"特等奖特等奖特等奖"];
        self.lb_title.font = [NSFont systemFontOfSize:30];
        self.lb_title.textColor = [NSColor whiteColor];
        self.lb_title.backgroundColor = [NSColor clearColor];
        
        self.right_line = [[NSTextField alloc]init];
        self.right_line.backgroundColor = [NSColor whiteColor];
        [self.right_line setEditable:NO];
        [self.right_line setSelectable:NO];
        [self.right_line setBezeled:NO];
        [self.right_line setBordered:NO];
        
        self.left_line = [[NSTextField alloc]init];
        self.left_line.backgroundColor = [NSColor whiteColor];
        [self.left_line setEditable:NO];
        [self.left_line setSelectable:NO];
        [self.left_line setBezeled:NO];
        [self.left_line setBordered:NO];
        
        self.subTitle = [[NSTextField alloc]init];
        self.subTitle.backgroundColor = [NSColor whiteColor];
        [self.subTitle setEditable:NO];
        [self.subTitle setSelectable:NO];
        [self.subTitle setBezeled:NO];
        [self.subTitle setBordered:NO];
        [self.subTitle setFont:[NSFont systemFontOfSize:16]];
        [self.subTitle setAlignment:NSTextAlignmentCenter];
        self.subTitle.textColor = [NSColor whiteColor];
        self.subTitle.backgroundColor = [NSColor clearColor];
        
        self.topview = [[NSView alloc]init];
        [self addSubview:self.topview];
        
        [self.topview addSubview:self.left_line];
        [self.topview addSubview:self.right_line];
        [self.topview addSubview:self.lb_title];
        [self addSubview:self.subTitle];
        
        [self.topview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(0));
            make.leading.equalTo(@(0));
            make.trailing.equalTo(@(0));
            make.height.equalTo(@(50));
        }];
        
        [self.lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(@(0));
            make.height.equalTo(@(36));
            make.width.greaterThanOrEqualTo(@(40));
        }];
        
        [self.left_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.lb_title.mas_leading).offset(-20);
            make.centerY.equalTo(@(0));
            make.height.equalTo(@(1));
            make.width.equalTo(@(80));
        }];
        
        [self.right_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.lb_title.mas_trailing).offset(20);
            make.centerY.equalTo(@(0));
            make.height.equalTo(@(1));
            make.width.equalTo(@(80));
        }];
        
        [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.topview.mas_bottom);
            make.leading.equalTo(@(0));
            make.trailing.equalTo(@(0));
            make.height.equalTo(@(30));
        }];
    }
    return self;
}

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];
    
    // Drawing code here.
}

@end
